import requests

class RequestSpider(object):
    def __init__(self):
        url = 'https://www.baidu.com'
        headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
        }
        self.response = requests.get(url, headers=headers)

    def run(self):
        data = self.response.content
        # 1.获取请求头
        request_header = self.response.request.headers
        print(request_header)
        # 2.获取响应头
        response_header = self.response.headers
        print(response_header)
        # 3.获取响应状态码
        code = self.response.status_code
        print(code)
        # 4.获取请求cookie
        request_cookie = self.response.request._cookies
        print(request_cookie)
        # 5.获取响应cookie
        response_cookie = self.response.cookies
        print(response_cookie)

RequestSpider().run()